266A - Stones on the Table - CodeForces Solution


implementation *800

Please click on ads to support us..

Python Code:

N = int(input())
col = input()

count =0
for i in range(0,len(col)-1):
    if col[i] == col[i+1]:
        count+=1
    else:
        continue
print(count)

C++ Code:

#include <iostream>
#include <string>



using namespace std;






int main(){
	int n,c=0;
	string str;
	cin>>n>>str;

	for(int i=0;i<n-1;i++){
		if(str[i]==str[i+1]){
			c++;
		}
	}
	cout<<c;
	return 0;
}


Comments

Submit
0 Comments
More Questions

1438A - Specific Tastes of Andre
1711C - Color the Picture
1194C - From S To T
110B - Lucky String
1114A - Got Any Grapes
224B - Array
125B - Simple XML
567B - Berland National Library
431B - Shower Line
282C - XOR and OR
1582B - Luntik and Subsequences
609A - Флеш-карты
1207A - There Are Two Types Of Burgers
371C - Hamburgers
343B - Alternating Current
758B - Blown Garland
1681B - Card Trick
1592A - Gamer Hemose
493D - Vasya and Chess
1485A - Add and Divide
337B - Routine Problem
1392D - Omkar and Bed Wars
76E - Points
762C - Two strings
802M - April Fools' Problem (easy)
577B - Modulo Sum
1555B - Two Tables
1686A - Everything Everywhere All But One
1469B - Red and Blue
1257B - Magic Stick